package com.chang.spring6.iocXML;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestUser {
    private static Logger logger = LoggerFactory.getLogger("TestUser");

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        User user = (User) context.getBean("user1");
        System.out.println("根据id获取bean" + user);
        logger.info("user输出成功>>>>>");

        // Water user2 = context.getBean(Water.class);
        // System.out.println("根据类型获取bean" + user2);

        // 根据id和类型进行输出
        User user3 = context.getBean("user", User.class);
        System.out.println("根据id和类型获取bean对象" + user3);
    }
}
